﻿////#include <iostream>
////using namespace std;
////class Person
////{
////protected:
////	string name, sex;
////public:
////	Person(string name_, string sex_) :name(name_), sex(sex_) {};
////	virtual void print()
////	{
////		cout << name << endl<< sex << endl<<"\n";
////	}
////};
////class Student :public Person
////{
////protected:
////	double height;
////public:
////	Student(string name_, string sex_, double h) : Person(name_, sex_), height(h) {};
////	virtual  void print()
////	{
////		cout << name << endl << sex << endl << height << endl<<"\n";
////	}
////};
////class  Teacher :public Student
////{
////protected:
////	int age;
////public:
////	Teacher(string name_, string sex_, double h, int age_) :Student(name_, sex_, h), age(age_) {};
////	void print()
////	{
////		cout << name << endl << sex << endl << height << endl << age<<endl<<"\n";
////	}
////};
////int main()
////{
////	Person* p;
////	Person person("lili", "女");
////	Student student("nana", "男",189);
////	Teacher teacher("mana", "男", 189, 20);
////	//person.print();
////	//student.print();
////	//teacher.print();//多态，名字一样，但是打印的东西不一样
////	//lili 女 nana 男 189 mana 男 189 20
////	p = &person;
////	p->print();
////	p = &student;
////	p->print();
////	p = &teacher;
////	p->print();//lili 女 nana 男 只能打印前两个；
////	//Person 加上virtual 后才能各自lili 女 nana 男 189 mana 男 189 20打印
////	return 0;
////}
//#include <iostream>
//using namespace std;
//class Person
//{
//protected:
//	string name, sex;
//public:
//	Person(string name_, string sex_) :name(name_), sex(sex_) {};
//	virtual void print() = 0;//纯虚数，后面的自己再重新定义即可
//};
//class Student :public Person
//{
//protected:
//	double height;
//public:
//	Student(string name_, string sex_, double h) : Person(name_, sex_), height(h) {};
//	void print()
//	{
//		cout << name << endl << sex << endl << height << endl << "\n";
//	}
//};
//class  Teacher :public Student
//{
//protected:
//	int age;
//public:
//	Teacher(string name_, string sex_, double h, int age_) :Student(name_, sex_, h), age(age_) {};
//	void print()
//	{
//		cout << name << endl << sex << endl << height << endl << age << endl << "\n";
//	}
//};
//int main()
//{
//	Person* p;
//	Student student("nana", "男", 189);
//	Teacher teacher("mana", "男", 189, 20);
//	p = &student;
//	p->print();
//	p = &teacher;
//	p->print();//lili 女 nana 男 只能打印前两个；
//	//Person 加上virtual 后才能各自lili 女 nana 男 189 mana 男 189 20打印
//	return 0;
//}
//#include <iostream>
//#include <iomanip>
//using namespace std;
//class Shape
//{
//public:
//	virtual double area() 
//	{ 
//		return 0;
//	}
//};
//class Circle:public  Shape
//{
//protected:
//	double r_;
//public:
//	Circle(double r) :r_(r) {};
//	virtual double area()
//	{
//		return 3.14 * r_ * r_;
//	}
//};
//class Square:public  Shape
//{
//protected:
//    double b_;
//public:
//	Square(double b) :b_(b) {};
//	virtual double area()
//	{
//		return b_ * b_;
//	}
//};
//class Rectangle :public  Shape
//{
//protected:
//	double c_, k_;
//public:
//	Rectangle(double c,double k) :c_(c),k_(k) {};
//	virtual double area()
//	{
//		return c_ * k_;
//	}
//	void print()
//	{
//		cout << area() << endl;
//	}
//};
//int main()
//{
//	int t;
//	double r, b, c, k;
//	cin >> t;
//	for (int i = 0; i < t; i++)
//	{
//		cin >> r >> b >> c >> k;
//		Shape* p;
//		Circle circle(r);
//		Square square(b);
//		Rectangle rectangle(c, k);
//		p = &circle;
//		cout << fixed << setprecision(2) << p->area() << endl;
//		p = &square;
//		cout << fixed << setprecision(2) << p->area() << endl;
//		p = &rectangle;
//		cout << fixed << setprecision(2) << p->area() << endl;
//	}
//	return 0;
//}
//#include <iostream>
//#include <iomanip>
//using namespace std;
//class Vehicle
//{
//protected:
//     string id_;
//public:
//    Vehicle(string id) :id_(id) {};
//    virtual void display() = 0; 
//};
//class Car :public Vehicle
//{
//protected:
//    int quality_, h;
//public:
//    Car(string id, int quality, int weight) :Vehicle(id), quality_(quality), h(weight) {};
//    virtual void display()
//    {
//        int money = quality_ * 8 + h * 2;
//        cout << id_ << " " << money << endl;
//    }
//};
//class Truck :public Vehicle
//{
//protected:
//    int h;
//public:
//    Truck(string id, int weight) :Vehicle(id), h(weight) {};
//    virtual void display()
//    {
//        int money =h* 5;
//        cout << id_ << " " << money << endl;
//    }
//};
//class Bus :public Vehicle
//{
//protected:
//    int quality_;
//public:
//    Bus(string id, int quality) :Vehicle(id), quality_(quality) {};
//    virtual void display()
//    {
//        int money = quality_ * 30;
//        cout << id_ << " " << money << endl;
//    }
//};
//int main()
//{
//    int t,type,quality,weight;
//    string id;
//    cin >> t;
//    Vehicle* p;
//    for (int i = 0; i < t; i++)
//    {
//        cin >> type;
//        if (type == 1)
//        {
//            cin >> id >> quality >> weight;
//            Car car(id, quality, weight);
//            p = &car;
//            p->display();
//        }
//        else if (type == 2)
//        {
//            cin >> id >> weight;
//            Truck truck(id, weight);
//            p = &truck;
//            p->display();
//        }
//        else
//        {
//            cin >> id >> quality;
//            Bus bus(id, quality);
//            p = &bus;
//            p->display();
//        }
//    }
//    return 0;
//}
//#include <iostream>
//#include <iomanip>
//using namespace std;
//class Animal
//{
//protected:
//    string name_;
//public:
//    Animal(string name) :name_(name) {};
//    virtual void speak() = 0;
//};
//class Dog:public Animal
//{
//public:
//    Dog(string name) : Animal(name) {};
//    virtual void speak()
//    {
//        cout << "Hello,I am " << name_ << ",WangWang." << endl;
//    }
//};
//class Tiger :public Animal
//{
//public:
//   Tiger(string name) : Animal(name) {};
//    virtual void speak()
//    {
//        cout << "Hello,I am " << name_ << ",AOOO." << endl;
//    }
//};
//class Duck :public Animal
//{
//public:
//    Duck(string name) : Animal(name) {};
//    virtual void speak()
//    {
//        cout << "Hello,I am " << name_ << ",GAGA." << endl;
//    }
//};
//class Pig :public Animal
//{
//public:
//    Pig(string name) : Animal(name) {};
//    virtual void speak()
//    {
//        cout << "Hello,I am " << name_ << ",HENGHENG." << endl;
//    }
//};
//int main()
//{
//    int t,age;
//    string animal,name;
//    cin >> t;
//    Animal* p;
//    for (int i = 0; i < t; i++)
//    {
//        cin >> animal >> name >> age;
//            if (animal == "Dog")
//            {
//                Dog dog(name);
//                p = &dog;
//                p->speak();
//            }
//            else if (animal == "Duck")
//            {
//                Duck duck(name);
//                p = &duck;
//                p->speak();
//            }
//            else if (animal == "Pig")
//            {
//                Pig pig(name);
//                p = &pig;
//                p->speak();
//            }
//            else if(animal == "Tiger")
//            {
//                Tiger tiger(name);
//                p = &tiger;
//                p->speak();
//            }
//            else
//            {
//                cout << "There is no " << animal << " in our Zoo." << endl;
//            }
//    }
//    return  0;
//}
//#include <iostream>
//#include <iomanip>
//using namespace std;
//class BaseAccount
//{
//protected:
//	string name_, account_;
//	int balance_;
//public:
//	BaseAccount(string name, string account, int balance) :name_(name), account_(account), balance_(balance) {};
//	virtual void deposit(int despoit)
//	{
//		balance_ = balance_ + despoit;
//	}
//	virtual void withdraw(int withdraw)
//	{
//		if (balance_ < withdraw)
//		{
//			cout << "insufficient" << endl;
//		}
//		else
//		balance_ = balance_ - withdraw;
//	}
//	virtual  void display()
//	{
//		cout << name_<<" "<<account_ << " Balance:" << balance_ << endl;
//	}
//};
//class BasePlus:public BaseAccount
//{
//protected:
//	int limit = 5000;
//	int limitsum;
//public:
//	BasePlus(string name, string account, int balance) :BaseAccount(name, account, balance), limit(5000), limitsum(5000) {};
//	virtual void deposit(int despoit)
//	{
//		balance_ = balance_ + despoit;
//	}
//	virtual void withdraw(int withdraw)
//	{
//		balance_ = balance_ - withdraw;
//		if (balance_ < 0)
//		{
//			limitsum = limitsum + balance_;
//			if (limitsum < 0)
//			{
//				limitsum = limitsum - balance_;
//				balance_ = balance_ + withdraw;
//				cout << "insufficient" << endl;
//			}
//			else
//				balance_ = 0;
//		}
//	}
//	virtual void display()
//	{
//		cout << name_ << " " << account_ << " Balance:" << balance_ << " "  << "limit:" << limitsum << endl;
//	}
//};
//int main()
//{
//	BaseAccount* p;
//	int t ,balance,deposit1,deposit2,withdraw1, withdraw2;
//	string name;
//	char account[20];
//	cin >> t;
//	for (int i = 0; i < t; i++)
//	{
//		cin >> name >> account >> balance >> deposit1 >> withdraw1 >> deposit2 >>withdraw2;
//		if (account[1] == 'A')
//		{
//			BaseAccount baseaccount(name, account, balance);
//			p = &baseaccount;
//			p->deposit(deposit1);
//			p->withdraw(withdraw1);
//			p->deposit(deposit2);
//			p->withdraw(withdraw2);
//			p->display();
//		}
//		else if(account[1] == 'P')
//		{
//			BasePlus basePlus(name, account, balance);
//			p = &basePlus;
//			p->deposit(deposit1);
//			p->withdraw(withdraw1);
//			p->deposit(deposit2);
//			p->withdraw(withdraw2);
//			p->display();
//		}
//	}
//	return 0;
//}
#include <iostream>
#include <math.h>
using namespace std;
class Group
{
public:
	virtual int add(int x, int y) = 0;
	virtual int sub(int x, int y) = 0;
};
class GroupA:public  Group
{
public:
	virtual int add(int x, int y)
	{
		return x + y;
	}
	virtual int sub(int x, int y)
	{
		return x - y;
	}
};
class GroupB :public  Group
{
public:
	virtual int add(int x, int y)
	{
		return x + y;
	}
	virtual int sub(int x, int y)
	{
		int  sum = 0, sum1 = 0, count = 0;
		while (x > 0 || y > 0)
		{
			int g = x % 10;
			int h = y % 10;
			if (g<h )
			{
				sum1 = g + 10-h;
			}
			else
			{
				sum1 = g - h;
			}
			sum = sum+sum1 * pow(10,count);
			x = x / 10;
			y = y / 10;
			count++;
		}
		return sum;
	}
};
class GroupC :public  Group
{
public:
	virtual int add(int x, int y)
	{
		int  sum = 0, sum1 = 0, count = 0;
		while (x > 0 || y > 0)
		{
			int g = x % 10;
			int h = y % 10;
			sum1 = g + h;
			if (sum1 >10)
			{
				sum1 = sum1 % 10;
			}
			sum = sum + sum1 * pow(10, count);
			x = x / 10;
			y = y / 10;
			count++;
		}
		return sum;
	}
	virtual int sub(int x, int y)
	{
		int  sum = 0, sum1 = 0, count = 0;
		while (x > 0 || y > 0)
		{
			int g = x% 10;
			int h = y % 10;
			if (g < h)
			{
				sum1 = g + 10 - h;
			}
			else
			{
				sum1 = g - h;
			}
			sum = sum + sum1 * pow(10, count);
			x = x / 10;
			y = y / 10;
			count++;
		}
		return sum;
	}
};
int main()
{
	int t,type, x_, y_;
	cin >> t;
	char op;
	Group* p=NULL;
	for (int i = 0; i < t; i++)
	{
		cin >> type >> x_ >> op >> y_;
		if (type == 1)
		{
			GroupA group;
			p = &group;
			if (op == '+')
			{
				p->add(x_, y_);
				cout << p->add(x_, y_) << endl;
			}
			else
			{
				p->sub(x_, y_);
				cout << p->sub(x_, y_) << endl;
			}
		}
		else if (type == 2)
		{
			GroupB group;
			p = &group;
			if (op == '+')
			{
				p->add(x_, y_);
				cout << p->add(x_, y_) << endl;
			}
			else
			{
				p->sub(x_, y_);
				cout << p->sub(x_, y_) << endl;
			}
		}
		else if (type == 3)
		{
			GroupC group;
			p = &group;
			if (op == '+')
			{
				p->add(x_, y_);
				cout << p->add(x_, y_) << endl;
			}
			else
			{
				p->sub(x_, y_);
				cout << p->sub(x_, y_) << endl;
			}
		}
	}
	return 0;
}